import  axios from 'axios'
import { Message } from 'element-ui'
import store from '@/store';

const http=axios.create({
	baseURL:''
});

//请求拦截
http.interceptors.request.use(
  config=>{
	  config.headers["Content-Type"]="application/x-www-form-urlencoded;charset=UTF-8";
	  config.headers["token"]=localStorage.getItem("token");
	  return config;
  },
  error=>{
	  return Promise.reject(error);
  }
)

//响应拦截
http.interceptors.response.use(
	response=>{
	   return response;
	},
	error=>{
		if(error.status===404){
			Message({
			  message: "服务器内部错误!",
			  type: 'error',
			  duration: 5000
			})
		}
	   return Promise.reject(error);
	}
)

export default http;
 